package com.gxa.service.points.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.dto.pointsdto.IntegralDto;
import com.gxa.entity.points.ExchangeRecord;
import com.gxa.entity.points.Integral;
import com.gxa.mapper.points.IntegralMapper;
import com.gxa.service.points.IntegralService;
import com.gxa.vo.IntegralVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 积分表 服务实现类
 * </p>
 *
 * @author yjl
 * @since 2022-10-17 10:36:06
 */
@Service
public class IntegralServiceImpl extends ServiceImpl<IntegralMapper, Integral> implements IntegralService {

    @Autowired
    private IntegralMapper integralMapper;

    @Override
    public PageInfo<IntegralDto> queyAll(Integer PageNumber, Integer Count) {
        LambdaQueryWrapper<Integral> lqw = new LambdaQueryWrapper<Integral>();
        lqw.eq(Integral ::getIsDelete,0);
        Page<IntegralDto> page1 = PageHelper.startPage(PageNumber,Count);
        List<IntegralDto> integralDtos = this.integralMapper.queryAll(lqw);
        PageInfo<IntegralDto> pageInfo = new PageInfo<IntegralDto>(integralDtos);
        return pageInfo;
    }

    @Override
    public IntegralDto queryById(Integer id) {
        IntegralDto integralDto = this.integralMapper.queryById(id);
        return integralDto;
    }

    @Override
    public void delete(Integer id) {
        this.integralMapper.deleteById(id);
    }

    @Override
    public PageInfo<IntegralDto> queryByVo(IntegralVo integralVo) {
        Page<IntegralDto> page1 = PageHelper.startPage(integralVo.getPagenum(),integralVo.getCount());
        List<IntegralDto> integralDtos = this.integralMapper.queryByVo(integralVo);
        PageInfo<IntegralDto> pageInfo = new PageInfo<IntegralDto>(integralDtos);

        return pageInfo;
    }
}
